package com.zuper.demo.sessionlogin.base;

import com.zuper.demo.sessionlogin.constant.ErrorEnum;
import com.zuper.demo.sessionlogin.exception.BusinessException;

public class BaseResult {
	private boolean success;
	private Object result;
	private String errCode;
	private String errMsg;
	
	public BaseResult(boolean success) {
		this.success = success;
	}
	
	public BaseResult(boolean success, String msg) {
		if(success) {
			this.result = msg;	
		}else {
			this.errMsg = msg;
		}
		this.success = success;
	}
	
	public BaseResult(String errCode, String errMsg) {
		super();
		this.success = false;
		this.errCode = errCode;
		this.errMsg = errMsg;
	}
	
	
	public BaseResult(ErrorEnum enm) {
		super();
		this.success = false;
		this.errCode = enm.code();
		this.errMsg = enm.msg();
	}
	
	public BaseResult(Object result) {
		super();
		this.success = true;
		this.setResult(result);
	}
	
	public BaseResult(BusinessException ex) {
		super();
		this.success = false;
		this.errCode = ex.code();
		this.errMsg = ex.msg();
	}
	
	public BaseResult() {
		super();
	}
	
	public boolean getSuccess() {
		return success;
	}
	public void setSuccess(boolean success) {
		this.success = success;
	}
	public String getErrCode() {
		return errCode;
	}
	public void setErrCode(String errCode) {
		this.errCode = errCode;
	}
	public String getErrMsg() {
		return errMsg;
	}
	public void setErrMsg(String errMsg) {
		this.errMsg = errMsg;
	}
	public Object getResult() {
		return result;
	}
	public void setResult(Object result) {
		this.result = result;
	}
	
	
}
